package org.apache.commons.httpclient.util;

import java.util.BitSet;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.URIException;

public class URIUtil
{
  protected static final BitSet empty = new BitSet(1);

  public static String decode(String paramString)
    throws URIException
  {
    try
    {
      String str = EncodingUtil.getString(URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(paramString)), URI.getDefaultProtocolCharset());
      return str;
    }
    catch (DecoderException localDecoderException)
    {
      throw new URIException(localDecoderException.getMessage());
    }
  }

  public static String decode(String paramString1, String paramString2)
    throws URIException
  {
    return Coder.decode(paramString1.toCharArray(), paramString2);
  }

  public static String encode(String paramString, BitSet paramBitSet)
    throws URIException
  {
    return encode(paramString, paramBitSet, URI.getDefaultProtocolCharset());
  }

  public static String encode(String paramString1, BitSet paramBitSet, String paramString2)
    throws URIException
  {
    return EncodingUtil.getAsciiString(URLCodec.encodeUrl(paramBitSet, EncodingUtil.getBytes(paramString1, paramString2)));
  }

  public static String encodeAll(String paramString)
    throws URIException
  {
    return encodeAll(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodeAll(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, empty, paramString2);
  }

  public static String encodePath(String paramString)
    throws URIException
  {
    return encodePath(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodePath(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, URI.allowed_abs_path, paramString2);
  }

  public static String encodePathQuery(String paramString)
    throws URIException
  {
    return encodePathQuery(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodePathQuery(String paramString1, String paramString2)
    throws URIException
  {
    int i = paramString1.indexOf(63);
    if (i < 0);
    for (String str = encode(paramString1, URI.allowed_abs_path, paramString2); ; str = encode(paramString1.substring(0, i), URI.allowed_abs_path, paramString2) + '?' + encode(paramString1.substring(i + 1), URI.allowed_query, paramString2))
      return str;
  }

  public static String encodeQuery(String paramString)
    throws URIException
  {
    return encodeQuery(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodeQuery(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, URI.allowed_query, paramString2);
  }

  public static String encodeWithinAuthority(String paramString)
    throws URIException
  {
    return encodeWithinAuthority(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodeWithinAuthority(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, URI.allowed_within_authority, paramString2);
  }

  public static String encodeWithinPath(String paramString)
    throws URIException
  {
    return encodeWithinPath(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodeWithinPath(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, URI.allowed_within_path, paramString2);
  }

  public static String encodeWithinQuery(String paramString)
    throws URIException
  {
    return encodeWithinQuery(paramString, URI.getDefaultProtocolCharset());
  }

  public static String encodeWithinQuery(String paramString1, String paramString2)
    throws URIException
  {
    return encode(paramString1, URI.allowed_within_query, paramString2);
  }

  public static String getFromPath(String paramString)
  {
    if (paramString == null);
    label7: int k;
    label70: label76: for (String str = null; ; str = paramString.substring(k))
      while (true)
      {
        return str;
        int i = paramString.indexOf("//");
        if (i >= 0)
          if (paramString.lastIndexOf("/", i - 1) < 0);
        for (int j = 0; ; j = 0)
          while (true)
          {
            k = paramString.indexOf("/", j);
            if (k >= 0)
              break label76;
            if (i < 0)
              break label70;
            str = "/";
            break label7:
            j = i + 2;
          }
        str = paramString;
      }
  }

  public static String getName(String paramString)
  {
    if ((paramString == null) || (paramString.length() == 0));
    String str;
    for (Object localObject = paramString; ; localObject = str)
      while (true)
      {
        return localObject;
        str = getPath(paramString);
        int i = str.lastIndexOf("/");
        int j = str.length();
        if (i < 0)
          break;
        localObject = str.substring(i + 1, j);
      }
  }

  public static String getPath(String paramString)
  {
    if (paramString == null);
    label7: int k;
    int l;
    label132: for (String str = null; ; str = paramString.substring(k, l))
      while (true)
      {
        return str;
        int i = paramString.indexOf("//");
        if (i >= 0)
          if (paramString.lastIndexOf("/", i - 1) < 0);
        for (int j = 0; ; j = 0)
          while (true)
          {
            k = paramString.indexOf("/", j);
            l = paramString.length();
            if (paramString.indexOf(63, k) != -1)
              l = paramString.indexOf(63, k);
            if ((paramString.lastIndexOf("#") > k) && (paramString.lastIndexOf("#") < l))
              l = paramString.lastIndexOf("#");
            if (k >= 0)
              break label132;
            if (i < 0)
              break label126;
            str = "/";
            break label7:
            j = i + 2;
          }
        label126: str = paramString;
      }
  }

  public static String getPathQuery(String paramString)
  {
    if (paramString == null);
    label7: int k;
    int l;
    label94: label100: for (String str = null; ; str = paramString.substring(k, l))
      while (true)
      {
        return str;
        int i = paramString.indexOf("//");
        if (i >= 0)
          if (paramString.lastIndexOf("/", i - 1) < 0);
        for (int j = 0; ; j = 0)
          while (true)
          {
            k = paramString.indexOf("/", j);
            l = paramString.length();
            if (paramString.lastIndexOf("#") > k)
              l = paramString.lastIndexOf("#");
            if (k >= 0)
              break label100;
            if (i < 0)
              break label94;
            str = "/";
            break label7:
            j = i + 2;
          }
        str = paramString;
      }
  }

  public static String getQuery(String paramString)
  {
    if ((paramString == null) || (paramString.length() == 0));
    label13: int l;
    int i2;
    label129: for (String str = null; ; str = paramString.substring(i2, l))
      while (true)
      {
        return str;
        int i = paramString.indexOf("//");
        if (i >= 0)
          if (paramString.lastIndexOf("/", i - 1) < 0);
        for (int j = 0; ; j = 0)
          while (true)
          {
            int k = paramString.indexOf("/", j);
            l = paramString.length();
            int i1 = paramString.indexOf("?", k);
            if (i1 < 0)
              break label124;
            i2 = i1 + 1;
            if (paramString.lastIndexOf("#") > i2)
              l = paramString.lastIndexOf("#");
            if ((i2 >= 0) && (i2 != l))
              break label129;
            str = null;
            break label13:
            j = i + 2;
          }
        label124: str = null;
      }
  }

  protected static class Coder extends URI
  {
    public static String decode(char[] paramArrayOfChar, String paramString)
      throws URIException
    {
      return URI.decode(paramArrayOfChar, paramString);
    }

    public static char[] encode(String paramString1, BitSet paramBitSet, String paramString2)
      throws URIException
    {
      return URI.encode(paramString1, paramBitSet, paramString2);
    }

    public static String replace(String paramString, char paramChar1, char paramChar2)
    {
      StringBuffer localStringBuffer = new StringBuffer(paramString.length());
      int i = 0;
      int j = paramString.indexOf(paramChar1);
      if (j >= 0)
      {
        localStringBuffer.append(paramString.substring(0, j));
        localStringBuffer.append(paramChar2);
      }
      while (true)
      {
        i = j;
        if (j < 0);
        return localStringBuffer.toString();
        localStringBuffer.append(paramString.substring(i));
      }
    }

    public static String replace(String paramString, char[] paramArrayOfChar1, char[] paramArrayOfChar2)
    {
      for (int i = paramArrayOfChar1.length; i > 0; --i)
        paramString = replace(paramString, paramArrayOfChar1[i], paramArrayOfChar2[i]);
      return paramString;
    }

    public static boolean verifyEscaped(char[] paramArrayOfChar)
    {
      int i = 0;
      label2: int k;
      if (i < paramArrayOfChar.length)
      {
        k = paramArrayOfChar[i];
        if (k <= 128);
      }
      for (int j = 0; ; j = 1)
      {
        while (true)
        {
          return j;
          if (k != 37)
            break;
          int l = i + 1;
          if (Character.digit(paramArrayOfChar[l], 16) != -1)
          {
            i = l + 1;
            if (Character.digit(paramArrayOfChar[i], 16) != -1)
              break;
          }
          j = 0;
        }
        ++i;
        break label2:
      }
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.util.URIUtil
 * JD-Core Version:    0.5.3
 */